QT -= gui

TEMPLATE = lib
DEFINES += SIGNALSPECTRUM_LIBRARY

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

include(../../../public_library/fftw-3.6.10/fftw.pri)

SOURCES += \
    spectrumconversion.cpp \
    spectrum.cpp

HEADERS += \
    spectrumconversion.h \
    spectrum.h

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target


#配置文件指定字符集：
win32-msvc* {# MSVC
    QMAKE_CXXFLAGS += /utf-8
}
unix { #GCC/Clang等
    QMAKE_CXXFLAGS += -finput-charset=UTF-8
}

# 定义基础目标名称
CONFIG(release, debug|release){
    BASE_TARGET = SpectrumConversion
} else {
    BASE_TARGET = SpectrumConversiond
}

# 根据架构设置不同的目标文件名
win32 {# Windows平台
    contains(QT_ARCH, x86_64) {# 64位架构
        TARGET = $$BASE_TARGET-64
    } else {# 32位架构
        TARGET = $$BASE_TARGET-32
    }
} else { # 其他平台（如Linux、macOS）
    contains(QT_ARCH, x86_64) { # 64位架构
        TARGET = $$BASE_TARGET-64
    } else:contains(QT_ARCH, i386) {# 32位架构
        TARGET = $$BASE_TARGET-32
    }
}
#构建输出路径
DESTDIR = $$PWD/../../../public_library/spectrumconversion/lib
#构建临时文件
OBJECTS_DIR = $$PWD/../../build/makeout/$$TARGET/$$/obj
MOC_DIR = $$PWD/../../build/makeout/$$TARGET/moc



# ==========================复制重要头文件==============================
# 定义需要复制的头文件

HEADER_LIST = \
    $$PWD/spectrumconversion.h \
    $$PWD/SpectrumConversion \

# 定义需要复制的pri文件
PRI_PATH = $$PWD/spectrumconversion.pri

# 定义头文件目标目录路径
HEADER_DEST_DIR = $$PWD/../../../public_library/spectrumconversion/include/
# 定义pri目标目录路径
PRI_DEST_DIR = $$PWD/../../../public_library/spectrumconversion/

# 检查所有源文件是否存在
for(header, HEADER_LIST) {
    !exists($$header) {
        error("错误：源文件不存在 - $$header")
    }
}

# 确保头文件目标目录存在
!exists($$HEADER_DEST_DIR) {
    message("头文件目标目录不存在，尝试创建: $$HEADER_DEST_DIR")
    mkpath($$HEADER_DEST_DIR)
    !exists($$HEADER_DEST_DIR) {
        error("错误：无法创建头文件目标目录 - $$HEADER_DEST_DIR")
    }
}
# 确保目标目录存在
!exists($$PRI_DEST_DIR) {
    message("pri目标目录不存在，尝试创建: $$PRI_DEST_DIR")
    mkpath($$PRI_DEST_DIR)
    !exists($$PRI_DEST_DIR) {
        error("错误：无法创建pri目标目录 - $$PRI_DEST_DIR")
    }
}

# Windows平台配置（多文件复制）
win32 {
    # 转换头文件目标路径分隔符为反斜杠
    HEADER_DEST_DIR_WIN = $$replace(HEADER_DEST_DIR, /, \\)
    # 转换pri文件目标路径分隔符为反斜杠
    PRI_DEST_DIR_WIN = $$replace(PRI_DEST_DIR, /, \\)

    # 循环处理每个头文件
    for(header, HEADER_LIST) {
        header_win = $$replace(header, /, \\)
        # 为每个头文件添加复制命令，用&连接多个命令
        QMAKE_POST_LINK += cmd /c "copy /Y \"$$header_win\" \"$$HEADER_DEST_DIR_WIN\"" &
    }
    pri_win = $$replace(PRI_PATH, /, \\)
    QMAKE_POST_LINK += cmd /c "copy /Y \"$$pri_win\" \"$$PRI_DEST_DIR_WIN\"" &
    message("Windows多文件复制命令已配置")
}

# Linux平台配置（多文件复制）
unix {
    # 循环处理每个头文件文件
    for(header, HEADER_LIST) {
        # 为每个头文件添加复制命令，用;连接多个命令
        QMAKE_POST_LINK += cp -f "$$header" "$$HEADER_DEST_DIR" ;
    }
    QMAKE_POST_LINK += cp -f "$$PRI_PATH" "$$PRI_DEST_DIR" ;
    message("Linux多文件复制命令已配置")
}
